package com.aiowang.springboot.dynamic.activemq.utils;

import com.aiowang.springboot.dynamic.activemq.interfaces.DynamicActiveMQTransportListener;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.util.Map;

/**
 * @author aiowang
 * @date 2020-03-23 21:30
 */
public class DynamicActiveMQApplicationContextUtils implements ApplicationContextAware {


    //定义成员变量
    /**
     * DynamicActiveMQTransportListener实现类map集合
     */
    private static Map<String, DynamicActiveMQTransportListener> dynamicActiveMQTransportListenerImpls;


    /**
     * 获取指定类名的beans
     * @param applicationContext 上下文
     * @throws BeansException 错误
     */
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        dynamicActiveMQTransportListenerImpls = applicationContext.getBeansOfType(DynamicActiveMQTransportListener.class);
    }


    /**
     * dynamicActiveMQTransportListenerImpls的get方法
     * @return
     */
    public static Map<String, DynamicActiveMQTransportListener> getDynamicActiveMQTransportListenerImpls() {
        return dynamicActiveMQTransportListenerImpls;
    }

    /**
     * dynamicActiveMQTransportListenerImpls的set方法
     * @param res res
     */
    public static void setDynamicActiveMQTransportListenerImpls(Map<String, DynamicActiveMQTransportListener> res) {
        DynamicActiveMQApplicationContextUtils.dynamicActiveMQTransportListenerImpls = res;
    }
}

